﻿using System;
using System.Web;
using Ue.Framework.Web;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Infrastructure.Web.AsyncHandlers;
using Ue.Qcdz.Domain.Products;

namespace Ue.Qcdz.UI.Controller
{
    public class ProductController:AsyncResult
    {
        private IProductRepository productRepository;
        private Product product;
        public ProductController(AsyncCallback callback, HttpContext context, object state) : base(callback, context, state)
        {
            Guid guid = context.Request.GetQueryValue<Guid>("productId");
            productRepository = RepositoryFactory.GetRepository<IProductRepository, Product>();
            product = productRepository[guid];
        }
        public string ChangeState()
        {
            product.ChangeState();
            productRepository[product.Key] = product;
            return product.State.ToString();
        }

    }
}
